﻿using UnityEngine;
using System.Collections;

public class SafeZone : MonoBehaviour {
	public GameObject player;
	public bool Stunned;
	public AudioClip stunnedClip;
	public AudioSource src;
	
	// Use this for initialization
	void Start () {
		Stunned = false;
	}
	
	// Update is called once per frame
	void Update () {
		if (!Stunned && (player.transform.position.x > -10) && (player.transform.position.x < 10) && (player.transform.position.z > -10) && (player.transform.position.z < 10)) {
						GameObject.Find ("GlassHud").guiTexture.color = Color.green;

						Color color = GameObject.Find ("GlassHud").guiTexture.color;
						color.a = 0.3f;
						GameObject.Find ("GlassHud").guiTexture.color = color;
				} else if (!Stunned && (player.transform.position.x < -10 || player.transform.position.x > 10 || player.transform.position.z < -10 || player.transform.position.z > 10)) {
						GameObject.Find ("GlassHud").guiTexture.color = Color.gray;
						//GameObject.Find("GlassHud").renderer.material.color.a = 0.3f;
						Color color = GameObject.Find ("GlassHud").guiTexture.color;
						color.a = 0.3f;
						GameObject.Find ("GlassHud").guiTexture.color = color;
				} else if (Stunned) {
			GameObject.Find ("GlassHud").guiTexture.color = Color.yellow;
			//GameObject.Find("GlassHud").renderer.material.color.a = 0.3f;
			Color color = GameObject.Find ("GlassHud").guiTexture.color;
			color.a = 0.3f;
			GameObject.Find ("GlassHud").guiTexture.color = color;
				}
	}

	void getStun(){
		Stunned = true;
		src.audio.clip = stunnedClip;
		src.audio.Play();
	}

	void getUnStunned(){
		Stunned = false;
		src.audio.Stop();
	}

}
